<extend name="Public:common"/>
<block name="css">
    <style>
        .ul_head{background:#afafaf; color:#fff;padding:5px 10px;}
        .list-unstyled{padding:5px 10px; padding-left:20px; background:#f2f2f2;}
        .chosePrice{margin-left:5px;}
        .label-tip{margin-left:20px;}
    </style>
</block>
<block name="content">
    <div class="page-header" style="background-color: #fff!important"><h1><i class="fa fa-home"></i> 首页 &gt;产品管理&gt;线路发布</h1></div>

    <ul id="nav" class="nav nav-tabs">
        <li role="presentation" class=""><a href="javascript:void(0)">第一步基本信息</a></li>
        <li role="presentation" class=""><a href="javascript:void(0)">第二步价格计划</a></li>
        <li role="presentation" class=""><a href="javascript:void(0)">第三步行程安排</a></li>
        <li role="presentation" class=""><a href="javascript:void(0)">第四步签证添加</a></li>
        <li role="presentation" ><a href="javascript:void(0)">第五步附加产品</a></li>
        <li role="presentation" class="active"><a href="javascript:void(0)">第六步销售渠道</a></li>
    </ul>
    <div class="tab-content">
        <!-- 附加产品 第五步-->
        <div class="container">

            <form action="{:U('step6_action')}" method="post">
                <input type="hidden" name="id" value="{:I('id')}">
                <div class="row">
                    <div class="ul_head"> <input id="all" type="checkbox" class="se-all" > <label for="all">全渠道</label></div>
                    <ul class="list-unstyled all-item-ul">
                        <volist name="allChannel" id="vo">
                            <li>
                                <input id="all-item" class="all-item se-all" {$vo.checked} name="allChannel[{$key}][channel_id]" value="{$vo.channel_id}" type="checkbox">
                                <label for="all-item">{$vo.channel_name}</label>
                                <label for="" class="label label-info label-tip">选择价格:</label>
                                <select name="allChannel[{$key}][price_id]" id="">
                                    <volist name="priceList" id="vvo">
                                        <option  <if condition="$vo['price_id'] eq $vvo['price_id']">selected</if>  value="{$vvo.price_id}">{$vvo.price_name} 成人{$vvo.adult_price} 儿童{$vvo.child_price} <!--老人{$vvo.oldman_price}--></option>
                                    </volist>
                                </select>
                            </li>
                        </volist>

                    </ul>
                </div>
                <div class="row">
                    <div class="ul_head"> <input id="platform" type="checkbox"  class="un-all"> <label for="platform">线上-平台分销</label></div>
                    <ul class="list-unstyled platform-ul">
                        <volist name="platformList" id="vo">
                            <li>
                                <input id="platform-item-{$key}" class="platform-item un-all" {$vo.checked} name="platform[{$key}][platform_id]" value="{$vo.platform_id}"  type="checkbox">
                                <label for="platform-item-{$key}">{$vo.platform_name}</label>
                                <label for="" class="label label-info label-tip">选择价格:</label>
                                <select name="platform[{$key}][price_id]" >
                                    <volist name="priceList" id="vvo">
                                        <option <if condition="$vo['price_id'] eq $vvo['price_id']">selected</if>  value="{$vvo.price_id}">{$vvo.price_name} 成人{$vvo.adult_price} 儿童{$vvo.child_price} 老人{$vvo.oldman_price}</option>
                                    </volist>
                                </select>
                            </li>
                        </volist>

                    </ul>
                </div>

                <div class="row">
                    <div class="ul_head"> <input id="offLine" type="checkbox"  class="un-all"> <label for="offLine">线下-门店</label></div>
                    <ul class="list-unstyled offLine-ul">
                        <volist name="stores" id="vo">
                            <li>
                                <input id="offLine-item-{$key}" {$vo.checked} name="stores[{$key}][reseller_id]" value="{$vo.reseller_id}" class="offLine-item un-all"  type="checkbox">
                                <label for="offLine-item-{$key}">{$vo.reseller_name}</label>
                                <label for="" class="label label-info label-tip">选择价格:</label>
                                <select name="stores[{$key}][price_id]" >
                                    <volist name="priceList" id="vvo">
                                        <option <if condition="$vo['price_id'] eq $vvo['price_id']">selected</if>  value="{$vvo.price_id}">{$vvo.price_name} 成人{$vvo.adult_price} 儿童{$vvo.child_price} <!--老人{$vvo.oldman_price}--></option>
                                    </volist>
                                </select>
                            </li>
                        </volist>

                    </ul>
                </div>

                <div class="row">
                    <div class="ul_head"> <input id="reseller" type="checkbox" class="un-all"> <label for="reseller">分销商</label></div>
                    <ul class="list-unstyled reseller-ul">
                        <volist name="sellers" id="vo">
                            <li><input id="reseller-item-{$key}" {$vo.checked} name="sellers[{$key}][reseller_id]"  value="{$vo.reseller_id}" class="reseller-item un-all"  type="checkbox">
                                <label for="reseller-item-{$key}">{$vo.reseller_name}</label>
                                <label for="" class="label label-info label-tip">选择价格:</label>
                            <select name="sellers[{$key}][price_id]" >
                                <volist name="priceList" id="vvo">
                                    <option <if condition="$vo['price_id'] eq $vvo['price_id']">selected</if>  value="{$vvo.price_id}">{$vvo.price_name} 成人{$vvo.adult_price} 儿童{$vvo.child_price} <!--老人{$vvo.oldman_price}--></option>
                                </volist>
                            </select>
                            </li>
                        </volist>
                    </ul>
                </div>

                <div class="row text-center">
                    <a href="{:U('form_step5',array('id'=>I('id')))}" class="btn btn-info">上一步</a>
                    <input type="submit" class="btn btn-warning" value="确认并发布"/>
                </div>
            </form>

        </div>
    </div>
</block>
<block name="js">
    <script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
    <script>

        $(function () {
            isCheckedAll();
        });

        //全渠道全选事件
        $('body').on('change','.se-all',function () {
           if($(this).is(':checked')){
               $('.un-all').attr('disabled',true);
               $('.se-all').prop('checked',true);
           }else{
               $('.un-all').attr('disabled',false);
               $('.se-all').prop('checked',false);
           }
        });
        //单独销售选择
        $('body').on('change','.un-all',function () {
           if($(this).is(':checked')){
               $('.se-all').attr('disabled',true);
           }else{
               $('.se-all').attr('disabled',false);
           }
            isCheckedAll();
        });

        //平台选择
        $('body').on('change','#platform',function () {
            if($(this).is(':checked')){
                $('.platform-item').prop('checked',true);
            }else{
                $('.platform-item').prop('checked',false);
            }
            isCheckedAll();
        });

        //线下
        $('body').on('change','#offLine',function () {
            if($(this).is(':checked')){
                $('.offLine-item').prop('checked',true);
            }else{
                $('.offLine-item').prop('checked',false);
            }
            isCheckedAll();
        });
        //分销
        $('body').on('change','#reseller',function () {
            if($(this).is(':checked')){
                $('.reseller-item').prop('checked',true);
            }else{
                $('.reseller-item').prop('checked',false);
            }
            isCheckedAll();
        });

        $('body').on('change','.platform-item',function(){
            checkAll('platform','platform-item');isCheckedAll();
        });
        $('body').on('change','.offLine-item',function(){
            checkAll('offLine','offLine-item');isCheckedAll();
        });
        $('body').on('change','.reseller-item',function(){
            checkAll('reseller','reseller-item');isCheckedAll();
        });



        function checkAll(id,cls) {
            var itemCheckAll=true;
            $('.'+cls).each(function () {
                if(!$(this).is(':checked')){
                    itemCheckAll=false;
                    return false;
                }
            });
            if(itemCheckAll){
                $('#'+id).prop('checked',true);
            }else{
                $('#'+id).prop('checked',false);
            }

        }




        //判断全选
        function isCheckedAll(){
            var isChecked=true;
            $('.un-all').each(function () {
               if($(this).is(':checked')){
                   isChecked=false;
                   return false;
               }
            });

            if(isChecked){
                $('.se-all').prop('disabled',false);
            }else{
                $('.se-all').prop('checked',false);
                $('.se-all').prop('disabled',true);
            }
        }

    </script>
</block>

